<?php

abstract class Dcmp_Model_Review extends Dcmp_Model_Status {

    public function __construct() {
        parent::__construct();
    }

    public function review($status, $id){
        $ids = is_array($id)? $id: array($id);
        Kd_Data_Dcl_Update::create()
            ->into($this->getTable()->getName())
            ->value('status', ':status:s')
            ->value('reviewer_id', App::getIdentity()->getId())
            ->value('review_time', ':reviewTime:s')
            ->where()
                ->contain($this->getIdProperty(), $this->getTable()->getIdColumn()->getParameterName())
                ->eq('status', "'pending'")
            ->closest()
            ->addParameter(array($this->getIdProperty()=>$ids,
                          'status'=>$status,
                          'reviewTime'=>date('Y-m-d H:i:s')))
            ->execute();
        return $this;
    }

    protected function initializeTable($table) {
        $this->getTable()->createColumn('reviewer_id', 'integer')->setInsertable(FALSE);
        $this->getTable()->createColumn('review_time', 'datetime')->setInsertable(FALSE);
        parent::initializeTable($table);
    }

}